angular.module('commentService', [])

	.factory('User', function($http) {

		return {
			get : function() {
				return $http.get('/benhvien_laravel/public/api/users');
			},
			login : function(user) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/login',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(user)
				});
			}
		}
	})

.factory('Contact', function($http) {

		return {
			get : function() {
				return $http.get('/benhvien_laravel/public/api/contacts');
			},
			show : function(id) {
				return $http.get('/benhvien_laravel/public/api/contacts/' + id);
			},
			save : function(newUser) {
				return $http({
					method: 'POST',
					url: '/contacts/public/api/contacts',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(newUser)
				});
			},
			update : function(id, newUser) {
				return $http({
					method: 'PUT',
					url: '/contacts/public/api/contacts/'+id,
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(newUser)
				});
			}
		}
	})

.factory('Nursingrecord', function($http) {

		return {
			save : function(nurserecord) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/api/nurserecord',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(nurserecord)
				});
			},
			update : function(id, nurserecord) {
				return $http({
					method: 'PUT',
					url: '/benhvien_laravel/public/api/nurserecord/'+id,
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(nurserecord)
				});
			},
			checkrecord : function(id_contact) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/checkrecord',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(id_contact)
				});
			}
		}

	})

.factory('Drugchart', function($http) {

		return {
			save : function(drugchart) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/api/drugcharts',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(drugchart)
				});
			},
			update : function(id, drugchart) {
				return $http({
					method: 'PUT',
					url: '/benhvien_laravel/public/api/drugcharts/'+id,
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(drugchart)
				});
			},
			checkdrugchart : function(id_contact) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/checkdrugchart',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(id_contact)
				});
			}
		}

	})


.factory('Operativerecord', function($http) {

		return {
			save : function(operativerecord) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/api/operativerecords',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(operativerecord)
				});
			},
			update : function(id, operativerecord) {
				return $http({
					method: 'PUT',
					url: '/benhvien_laravel/public/api/operativerecords/'+id,
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(operativerecord)
				});
			},
			checkpre : function(id_contact) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/checkpre',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(id_contact)
				});
			}
		}

	})
	
	// TABLE EPISODE REST API
.factory('Episode', function($http) {
		return {
			save : function(episode) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/api/episodes',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(episode)
				});
			},
			update : function(id, episode) {
				return $http({
					method: 'PUT',
					url: '/benhvien_laravel/public/api/episodes/'+id,
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(episode)
				});
			},
			show : function(id) {
				return $http.get('/benhvien_laravel/public/api/episodes/' + id);
			},
			findbycontactid : function(id_contact) {
				return $http({
					method: 'POST',
					url: '/benhvien_laravel/public/findbycontactid',
					headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
					data: $.param(id_contact)
				});
			}
		}

	})
//END TABLE EPISODE REST API